package controller;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

import model.menupages.Creditpage;
import model.menupages.Gamepage;
import model.menupages.Hauptmenu;
import model.menupages.Highscorepage;

public class Heytetrisapplication {
	static Hauptmenu hauptmenu;
	static Gamefieldcontroller gfc;
	static Gamepage gamepage;

	// Navigationsereignisse

	public static void hauptmenupushed() {
		hauptmenu = new Hauptmenu();
	}

	public static void creditpushed() {
		Creditpage creditpage = new Creditpage();

	}

	public static void highscorepushed() {
		Highscorepage highscorepage = new Highscorepage();
	}

	public static void newgamepushed() {
		gamepage = new Gamepage();
	}

	// Spielereignisse werden über den gamfieldcontroller bearbeitet.

	public static void gamestarted(Gamepage gamepage) {
		gfc = new Gamefieldcontroller(gamepage);
	}

	public static void steinbewegen(int dir) {
		if (gfc != null) {
			gfc.aktiverSpielblock.setNewPos(gamepage,
					gfc.getVorhandeneSpielsteine(), dir);
		}
	}

	public static void end() {
		if (gfc != null) {
			gfc.gamelost();
			gfc = null;
			System.gc();
			System.runFinalization();
		}
	}

	public static void scoreAnzeigen(int score) {
		gamepage.score.setText("<html>Score:<br>" + score
				+ "</html>");
	}

	public static void gamepaused() {
		Gamefieldcontroller.pause();
		JOptionPane.showMessageDialog(new JFrame(), "go");
		Gamefieldcontroller.unpause();
		
	}

	public static void drehen() {
		if (gfc != null) {
			gfc.drehen();
		}
	}

}